//柠檬⽔找零（easy）: https://leetcode.cn/problems/lemonade-change/
class Solution
{
public:
	bool lemonadeChange(vector<int>& bills)
	{
		int five = 0, ten = 0;
		for (auto x : bills)
		{
			if (x == 5)
			{
				five++; // 5 元：直接收下
			}
			else if (x == 10) // 10 元：找零 5 元
			{
				if (five == 0) return false;
				five--; ten++;
			}
			else // 20 元：分情况讨论
			{
				if (ten && five) // 贪⼼
				{
					ten--; five--;
				}
				else if (five >= 3)
				{
					five -= 3;
				}
				else return false;
			}
		}
		return true;
	}
};